<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
	<title>清除定时器</title>
</head>
<body>
<p id="num"></p>
<a href="javascript:goOn();">继续</a>
<a href="javascript:stop();">停止</a>

<script type="text/javascript">
var oP = document.getElementById('num');
function times() {
	var oDate = new Date();
	var year = oDate.getFullYear();
	var month = oDate.getMonth()+1;
	month = month<10?'0'+month:month;
	var day = oDate.getDate();
	day =  day<10?'0'+day:day;
	var hour = oDate.getHours();
	var minute = oDate.getMinutes();
	var second = oDate.getSeconds();
	var str = '当前时间：'+year+'-'+month+'-'+day+'&nbsp;&nbsp;'+hour+':'+minute+':'+second;
	oP.innerHTML = str;
}
var timer = setInterval(times,1000);
// 让时间继续执行
function goOn() {
	// 首先清除上次的定时器
	clearInterval(timer);
	timer = setInterval(times,1000);

}
// 清除定时器
function stop() {
	clearInterval(timer);
}

</script>
</body>
</html>